package org.example;
public class SkillManager {
    private String skillType;
    private int skillCount = 0;
    private int doubleScoreCharges = 0; // 双倍收获激活次数
    private boolean isSprintActive = false;
    private boolean isTransportActive = false;
    public SkillManager(String skillType) {
        this.skillType = skillType;
        if(skillType.equals("双倍收获")){
            skillCount = 3;
        }
        if(skillType.equals("冲刺")){
            skillCount = 3;
        }
        if(skillType.equals("穿梭")){
            skillCount = 2;
        }

        if(skillType.equals("无")){
            skillCount = 0;
        }
    }

    public void activateSkill() {
        if (skillCount > 0 && skillType.equals("双倍收获")) {
            doubleScoreCharges ++; // 激活一次
            skillCount--;
        }
        if (skillCount > 0 && skillType.equals("冲刺")) {
            isSprintActive = true;
            skillCount--;
        }
        if (skillCount > 0 && skillType.equals("穿梭")) {
            isTransportActive = true;
            skillCount--;
        }
        if (skillType.equals("无")) {
            return;
        }

    }
    // 检查双倍收获是否激活
    public boolean isDoubleScoreActive() {
        return doubleScoreCharges > 0;
    }
    // 添加技能次数
    public void addCharge() {
        skillCount++;
    }

    // 消耗双倍收获（吃到食物后调用）
    public void consumeDoubleScore() {
        if (doubleScoreCharges > 0) {
            doubleScoreCharges--;
        }
    }
    // 获取技能信息
    public String getSkillInfo() {
        return String.format("技能：%s:%d次", skillType, skillCount);
    }

    public String getSkillType() {
        return skillType;
    }

    public void setSkillType(String skillType) {
        this.skillType = skillType;
    }

    public boolean isSprintActive() {
        return isSprintActive;
    }

    public void setSprintActive(boolean sprintActive) {
        isSprintActive = sprintActive;
    }

    public boolean isTransportActive() {
        return isTransportActive;
    }

    public void setTransportActive(boolean transportActive) {
        isTransportActive = transportActive;
    }
}
